import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: "",
    isLogin: "登录"
  },
  mutations: {
    setUser(state, user) {
      state.user = user;
    },
    isLogin(state, msg) {
      state.isLogin = msg
    }
  },
  actions: {
  },
  modules: {
  },

  plugins: [
    createPersistedState({
      storage: window.localStorage,
      reducer(state) {
        return {
          user: state.user,
          isLogin: state.isLogin
        }
      }
    })
  ]
})
